{% extends "market/base.html" %}

{% block header %}
  <h1>{{client.name}}</h1>
{% endblock header %}

{% block content %}

<h2>
  <span class="label label-primary">当前资金</span>
</h2>
<p style="line-height:1.6">
  <ul class="list-group">
    <li class="list-group-item"> 资金总额：{{client.cash}}</li>
    <li class="list-group-item"> 冻结资金：{{client.frozen_cash}}</li>
    <li class="list-group-item"> 可用资金：{{client.flexible_cash}}</li>
    <li class="list-group-item"> 当前收益：{{client.profit}}</li>

  </ul>
</p>

<h2>
  <span class="label label-primary">当前持仓</span>
</h2>
<p style="line-height:1.6">
    <div class="row">
      <div class="col-md-12">
        <table class="table table-bordered">
          <thead>
            <tr>
              <th>证券代码</th>
              <th>总股数</th> <th>冻结股数</th> <th>可用股数</th>
              <th>成本价</th> <th>保本价</th> <th>最新价</th>
              <th>盈亏</th> <th>市值</th>
            </tr>
          </thead>
          
          <tbody>
            {% if holding %}
              {% for hold in holding %}
                <tr>
                  <td><a href="{{ hold.get_stock_url }}">{{hold.stock_symbol}}</a></td>
                  <td>{{hold.vol}}</td>
                  <td>{{hold.frozen_vol}}</td>
                  <td>{{hold.available_vol}}</td>
                  <td>{{hold.cost}}</td>
                  <td>{{hold.price_guaranteed}}</td>
                  <td>{{hold.last_price}}</td>
                  <td>{{hold.profit}}</td>
                  <td>{{hold.value}}</td>
               </tr>
              {% endfor %}
            {% else %}
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td>
                <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td>
                <td>&nbsp;</td> <td>&nbsp;</td>
              </tr>
            {% endif %}
          </tbody>
          
        </table>
      </div>
    </div>

<h2>
  <span class="label label-info">当前委托</span>
</h2>
<p style="line-height:1.6">
    <div class="row">
      <div class="col-md-12">
        <table class="table table-bordered">
          <thead>
            <tr>
              <th>证券代码</th>
              <th>委托方向</th> <th>委托价格</th> <th>委托数量</th>
              <th>委托时间</th> 
              <th>成交均价</th> <th>成交数量</th>
            </tr>
          </thead>
          
          <tbody>
            {% if commission %}
              {% for com in commission %}
                <tr>
                  <td><a href="{{ com.stock_corr.get_absolute_url }}">{{com.stock_symbol}}</a></td>
                  <td>
                    {% if com.operation == 'b' %}
                      买入
                    {% else %}
                      卖出
                    {% endif %}
                  </td>
                  <td>{{com.price_committed}}</td>
                  <td>{{com.vol_committed}}</td>
                  <td>{{com.date_committed}}</td>
                  <td>{{com.price_traded}}</td>
                  <td>{{com.vol_traded}}</td>
               </tr>
              {% endfor %}
            {% else %}
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td>
                <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td>
              </tr>
            {% endif %}
          </tbody>
          
        </table>
      </div>
    </div>
</p>

<h2>
  <span class="label label-info">当前成交</span>
</h2>
<p style="line-height:1.6">
    <div class="row">
      <div class="col-md-12">
        <table class="table table-bordered">
          <thead>
            <tr>
              <th>证券代码</th>
              <th>成交方向</th> <th>成交价格</th> <th>成交数量</th>
              <th>成交时间</th> <th>成交对方</th>
            </tr>
          </thead>
          
          <tbody>
            {% if transaction %}
              {% for tran in transaction %}
                <tr>
                  <td><a href="#">{{tran.stock_symbol}}</a></td>
                  <td>
                    {% if tran.operation == 'b' %}
                      买入
                    {% else %}
                      卖出
                    {% endif %}
                  </td>
                  <td>{{tran.price_traded}}</td>
                  <td>{{tran.vol_traded}}</td>
                  <td>{{tran.date_traded}}</td>
                  <td>{{tran.counterpart}}</td>
               </tr>
              {% endfor %}
            {% else %}
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td>
                <td>&nbsp;</td> <td>&nbsp;</td>
              </tr>
            {% endif %}
          </tbody>
          
        </table>
      </div>
    </div>
</p>

{% endblock content %}
